namespace Example
{
    using System;
    using System.IdentityModel.Selectors;
    using System.IdentityModel.Tokens;

    public class CustomUserNameValidator : UserNamePasswordValidator
    {
        /// <summary>
        /// This method validates users.
        /// It allows in two users, test1 and test2 with passwords 1tset and 2tset respectively.
        /// </summary>
        /// <param name="userName">The user name.</param>
        /// <param name="password">The user password.</param>
        public override void Validate(string userName, string password)
        {
            if (null == userName)
            {
                throw new ArgumentNullException("userName");
            }

            if (null == password)
            {
                throw new ArgumentNullException("password");
            }

            if (!(userName == "test1" && password == "1tset") &&
                !(userName == "test2" && password == "2tset"))
            {
                throw new SecurityTokenException("Unknown Username or Incorrect Password");
            }
        }
    }
}